import java.io.*;
import java.awt.*;

public
class ChatClientThread extends Thread{
	BufferedReader in;
	boolean stopped;
	ChatClient chatClient;
	public ChatClientThread(ChatClient chatClient){
		super();
		this.in = chatClient.brSocket;
		this.chatClient = chatClient;
		stopped = false;
	}
	public void run(){
		String line = null;
		while(!stopped){
			try{
				line = in.readLine();
			}
			catch(IOException e){
				//chatClient.insertText("IO error: " + e + "\n");
				stopped = true;
				chatClient.clientThreadStopped();
				return;
			}
			if ((line == null) || line.equals("quit")){
				stopped = true;
				chatClient.clientThreadStopped();
				return;
			}
			chatClient.insertText(line + "\n");
		}
		chatClient.clientThreadStopped();
	}
}
